//
//  SGJTempObject.m
//  Sewage
//
//  Created by 优聚泰元 on 2017/6/6.
//  Copyright © 2017年 宗庆猛. All rights reserved.
//

#import "SGJTempObject.h"
#import <YYModel.h>
#import "SGJGrabOrderModel.h"
#import "SGJPoiModel.h"



@implementation SGJTempObject

+ (NSDictionary *)modelContainerPropertyGenericClass {
    // value should be Class or Class name.
    return @{@"poiRecords" : [SGJPoiModel class],
             @"sewageTask" : SGJGrabOrderModel.class,
             };
}

-(instancetype)initWithDict:(NSDictionary *)dict{
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key{
    [super setValue:value forKey:key];
    
    if ([key isEqualToString:@"poiRecords"]) {
        NSArray <NSDictionary *> *poiRecordsArr = value;
        
        NSMutableArray<SGJPoiModel *> *smallerArrM = [NSMutableArray array];
        [poiRecordsArr enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            SGJPoiModel *poiModel = [[SGJPoiModel alloc] init];
            [poiModel setValuesForKeysWithDictionary:obj];
            
            [smallerArrM addObject:poiModel];
        }];
        
        [super setValue:smallerArrM forKey:@"poiRecords"];
    }
    
    
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

@end
